{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-27T01:38:36.355494Z",
     "start_time": "2025-09-27T01:38:34.399971Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "\n",
    "# 每周学习时长\n",
    "X = [[5], [8], [10], [12], [15], [3], [7], [9], [14], [6]]\n",
    "\n",
    "# 数学考试成绩\n",
    "y = [55, 65, 70, 75, 85, 50, 60, 72, 80, 58]\n",
    "\n",
    "# 计算斯皮尔曼相关系数\n",
    "X = pd.DataFrame(X)\n",
    "y = pd.Series(y)\n",
    "print(X.corrwith(y, method=\"spearman\"))\n",
    "# 0.987879"
   ],
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0    0.987879\n",
      "dtype: float64\n"
     ]
    }
   ],
   "execution_count": 4
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
